package main

import (
	"dag2.0/gat1400-proxy/context"
	"dag2.0/gat1400-proxy/logger"
	"dag2.0/gat1400-proxy/server"
	"github.com/json-iterator/go/extra"
	"os"
	"os/signal"
)

func main() {
	//初始化日志
	logger.Init()

	//json模糊匹配
	extra.RegisterFuzzyDecoders()

	//初始化context
	context.Init()

	//启动1400server代理
	server.StartGat1400Server()

	//启动异步通知
	server.SubscribeNotification()

	//启动异步注册保活
	server.RegisterAndKeepAlive()

	//启动异步订阅
	server.Subscribe()

	//启动检测1400server的超时检测
	server.CheckKeepaliveSession()
	//server.CreatRootOrg("4819893","测试","1")


	//equipmentIds := []string{
	//	"a79f1622-f199-45c0-9fbd-0bb265ba38b5","04867906-cca4-4e69-b120-4595e82e812b","048fcce2-5632-4c2c-b143-66aa05aa41b7",
	//}
	//tollgateIds := []string{"0187e3a-f14b330-0bd2394-27d8c3f-cef6","01b9c3c-3742876-e69b722-3223270-b398","02e89a7-1a3b5dd-2f1b4b0-1137cf0-42d1"}
	//server.DealEquipment(equipmentIds)
	//server.GetTransmitTaskById("f5f4d2ef3f9c4101a46bfb3a775ef605")
	//subscribe := &model.Subscribe{
	//	SubscribeID:           "",
	//	Title:                 "",
	//	SubscribeDetail:       "",
	//	ResourceURI:           "",
	//	ApplicantName:         "",
	//	ApplicantOrg:          "",
	//	BeginTime:             "",
	//	EndTime:               "",
	//	ReceiveAddr:           "",
	//	ReportInterval:        0,
	//	Reason:                "",
	//	OperateType:           0,
	//	SubscribeStatus:       0,
	//	SubscribeCancelOrg:    "",
	//	SubscribeCancelPerson: "",
	//	CancelTime:            "",
	//	CancelReason:          "",
	//}
	//
	//s:= &model.SubscribeLib{
	//	Subscribe:   subscribe,
	//	TabID:       "",
	//	MangerID:   "",
	//	ManagerName: "",
	//	UpdateTime:  "",
	//	InsertTime:  "",
	//}
	//server.NotificationData(s)

	c := make(chan os.Signal, 1)
	signal.Notify(c, os.Interrupt, os.Kill)
	select {
	case <-c:
		break
	}
}
